import json
import requests
import sys
import pymongo
import talib
from factor import *

initFund=100000
fund=[]
# 
code='600010'
startdate='2015-06-02'
enddate='2016-06-02'
data=requests.get("http://localhost:3000/stock/history/time?code="+str(code)+"&start="+str(startdate)+"&end="+str(enddate))
lists=data.json()
print(lists[1])
"""
expected results
PS C:\quantaxis\analysis\python> python .\example.py
['2015-06-03', '6.650', '6.650', '6.500', '6.360', '5524387.00', '-0.150', '-2.26', '6.522', '6.752', '6.584', '6,709,222.70', '6,794,033.70', '6,807,961.80', '3.51']
"""
for item in lists:
    print (item)
    print (item[0])
    """
    expected results

    ['2016-05-25', '2.840', '2.860', '2.830', '2.810', '425533.31', '0.000', '0.00', '2.866', '2.856', '2.920', '860,444.06', '873,558.26', '786,931.30', '0.27']
    2016-05-25
    ['2016-05-26', '2.810', '2.870', '2.870', '2.770', '794664.00', '0.050', '1.77', '2.856', '2.857', '2.910', '704,760.36', '886,065.95', '787,090.14', '0.50']
    2016-05-26
    ['2016-05-27', '2.850', '2.870', '2.850', '2.820', '522716.97', '-0.020', '-0.70', '2.848', '2.860', '2.901', '591,625.25', '879,393.86', '772,030.30', '0.33']
    2016-05-27
    ['2016-05-30', '2.810', '2.940', '2.850', '2.790', '1112251.75', '0.000', '0.00', '2.844', '2.859', '2.891', '674,735.42', '904,095.74', '801,551.60', '0.71']
    2016-05-30
    ['2016-05-31', '2.840', '3.080', '3.050', '2.830', '2854263.75', '0.200', '7.02', '2.890', '2.876', '2.889', '1,141,885.96', '1,042,361.24', '907,747.91', '1.81']
    2016-05-31
    ['2016-06-01', '3.010', '3.080', '3.000', '2.980', '2053142.25', '-0.050', '-1.64', '2.924', '2.895', '2.886', '1,467,407.74', '1,163,925.90', '978,492.32', '1.30']
    2016-06-01
    ['2016-06-02', '2.970', '3.020', '2.990', '2.940', '1135590.38', '0.000', '0.00', '2.948', '2.902', '2.882', '1,535,593.02', '1,120,176.69', '1,007,985.72', '0.72']
    2016-06-02
    """

trade=requests.get("http://localhost:3000/backtest/ts?bidCode=000001&bidTime=2001-01-04&bidPrice=4.08")
#firstLine = trade.readline() 
assert trade.text == "success"

class account():
    def _init_(self):
        fund[0]=initFund
    def fund(self):
        return






#urllib.urlopen("http://localhost:3000/backtest/save?")